home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 June / PersonalComputerWorld-June2009-CoverdiscCD.iso / Software / Shareware / Mockups for Desktop 1.5.27 / MockupsForDesktop.air / MockupsAir.swf / scripts / ExportPNGConfirmationDialog.as < prev    next >
Encoding:
Text File  |  2009-03-03  |  9.3 KB  |  280 lines

  1. package
  2. {
  3.    import com.plus9.mockups.InputManager;
  4.    import com.plus9.mockups.dialogs.BaseDialog;
  5.    import flash.accessibility.*;
  6.    import flash.data.*;
  7.    import flash.debugger.*;
  8.    import flash.desktop.*;
  9.    import flash.display.*;
  10.    import flash.errors.*;
  11.    import flash.events.*;
  12.    import flash.external.*;
  13.    import flash.filesystem.*;
  14.    import flash.filters.*;
  15.    import flash.geom.*;
  16.    import flash.html.*;
  17.    import flash.html.script.*;
  18.    import flash.media.*;
  19.    import flash.net.*;
  20.    import flash.printing.*;
  21.    import flash.profiler.*;
  22.    import flash.system.*;
  23.    import flash.text.*;
  24.    import flash.ui.*;
  25.    import flash.utils.*;
  26.    import flash.xml.*;
  27.    import mx.binding.*;
  28.    import mx.containers.Canvas;
  29.    import mx.containers.ControlBar;
  30.    import mx.controls.Button;
  31.    import mx.controls.Text;
  32.    import mx.core.UIComponentDescriptor;
  33.    import mx.core.mx_internal;
  34.    import mx.events.PropertyChangeEvent;
  35.    import mx.styles.*;
  36.    
  37.    public class ExportPNGConfirmationDialog extends BaseDialog
  38.    {
  39.       public static const KIND_SINGLE:Boolean = false;
  40.       
  41.       public static const KIND_MULTIPLE:Boolean = true;
  42.       
  43.       public static const SELECTION_APPEND:uint = 0;
  44.       
  45.       public static const SELECTION_REPLACE:uint = 1;
  46.       
  47.       public static const SELECTION_REPLACE_ALL:uint = 2;
  48.       
  49.       protected var _existingFileName:String;
  50.       
  51.       public var selection:uint;
  52.       
  53.       private var _890562171_createNew:Button;
  54.       
  55.       public var fullPathToUse:String;
  56.       
  57.       private var _842245771_replace:Button;
  58.       
  59.       protected var _kind:Boolean = false;
  60.       
  61.       private var _981817656_message:Text;
  62.       
  63.       private var _documentDescriptor_:UIComponentDescriptor;
  64.       
  65.       private var _144754708_replaceAll:Button;
  66.       
  67.       protected var _newFile:File;
  68.       
  69.       public function ExportPNGConfirmationDialog()
  70.       {
  71.          _documentDescriptor_ = new UIComponentDescriptor({
  72.             "type":BaseDialog,
  73.             "propertiesFactory":function():Object
  74.             {
  75.                return {
  76.                   "width":524,
  77.                   "height":202,
  78.                   "childDescriptors":[new UIComponentDescriptor({
  79.                      "type":Canvas,
  80.                      "stylesFactory":function():void
  81.                      {
  82.                         this.right = "10";
  83.                         this.bottom = "10";
  84.                         this.left = "10";
  85.                         this.top = "10";
  86.                      },
  87.                      "propertiesFactory":function():Object
  88.                      {
  89.                         return {"childDescriptors":[new UIComponentDescriptor({
  90.                            "type":Text,
  91.                            "id":"_message",
  92.                            "propertiesFactory":function():Object
  93.                            {
  94.                               return {"percentWidth":100};
  95.                            }
  96.                         })]};
  97.                      }
  98.                   }),new UIComponentDescriptor({
  99.                      "type":ControlBar,
  100.                      "stylesFactory":function():void
  101.                      {
  102.                         this.horizontalAlign = "right";
  103.                      },
  104.                      "propertiesFactory":function():Object
  105.                      {
  106.                         return {"childDescriptors":[new UIComponentDescriptor({
  107.                            "type":Button,
  108.                            "id":"_replaceAll",
  109.                            "events":{"click":"___replaceAll_click"},
  110.                            "propertiesFactory":function():Object
  111.                            {
  112.                               return {"label":"Replace All  Files"};
  113.                            }
  114.                         }),new UIComponentDescriptor({
  115.                            "type":Button,
  116.                            "id":"_replace",
  117.                            "events":{"click":"___replace_click"},
  118.                            "propertiesFactory":function():Object
  119.                            {
  120.                               return {"label":"Replace the Existing File"};
  121.                            }
  122.                         }),new UIComponentDescriptor({
  123.                            "type":Button,
  124.                            "id":"_createNew",
  125.                            "events":{"click":"___createNew_click"},
  126.                            "propertiesFactory":function():Object
  127.                            {
  128.                               return {"label":"Create a new File"};
  129.                            }
  130.                         })]};
  131.                      }
  132.                   })]
  133.                };
  134.             }
  135.          });
  136.          super();
  137.          mx_internal::_document = this;
  138.          this.width = 524;
  139.          this.height = 202;
  140.       }
  141.       
  142.       public function set _replace(param1:Button) : void
  143.       {
  144.          var _loc2_:Object = this._842245771_replace;
  145.          if(_loc2_ !== param1)
  146.          {
  147.             this._842245771_replace = param1;
  148.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_replace",_loc2_,param1));
  149.          }
  150.       }
  151.       
  152.       [Bindable(event="propertyChange")]
  153.       public function get _createNew() : Button
  154.       {
  155.          return this._890562171_createNew;
  156.       }
  157.       
  158.       [Bindable(event="propertyChange")]
  159.       public function get _message() : Text
  160.       {
  161.          return this._981817656_message;
  162.       }
  163.       
  164.       public function set _createNew(param1:Button) : void
  165.       {
  166.          var _loc2_:Object = this._890562171_createNew;
  167.          if(_loc2_ !== param1)
  168.          {
  169.             this._890562171_createNew = param1;
  170.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_createNew",_loc2_,param1));
  171.          }
  172.       }
  173.       
  174.       protected function onClick(param1:Event) : void
  175.       {
  176.          switch(param1.target)
  177.          {
  178.             case _replaceAll:
  179.                fullPathToUse = _newFile.nativePath.substr(0,_newFile.nativePath.lastIndexOf("/") + 1) + _existingFileName + ".png";
  180.                selection = SELECTION_REPLACE_ALL;
  181.                break;
  182.             case _replace:
  183.                fullPathToUse = _newFile.nativePath.substr(0,_newFile.nativePath.lastIndexOf("/") + 1) + _existingFileName + ".png";
  184.                selection = SELECTION_REPLACE;
  185.                break;
  186.             case _createNew:
  187.                fullPathToUse = _newFile.nativePath;
  188.                selection = SELECTION_APPEND;
  189.          }
  190.          dispatchEvent(new Event("exportClick"));
  191.       }
  192.       
  193.       override public function initialize() : void
  194.       {
  195.          mx_internal::setDocumentDescriptor(_documentDescriptor_);
  196.          super.initialize();
  197.       }
  198.       
  199.       public function get kind() : Boolean
  200.       {
  201.          return _kind;
  202.       }
  203.       
  204.       public function ___replaceAll_click(param1:MouseEvent) : void
  205.       {
  206.          onClick(param1);
  207.       }
  208.       
  209.       public function ___replace_click(param1:MouseEvent) : void
  210.       {
  211.          onClick(param1);
  212.       }
  213.       
  214.       public function set _replaceAll(param1:Button) : void
  215.       {
  216.          var _loc2_:Object = this._144754708_replaceAll;
  217.          if(_loc2_ !== param1)
  218.          {
  219.             this._144754708_replaceAll = param1;
  220.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_replaceAll",_loc2_,param1));
  221.          }
  222.       }
  223.       
  224.       public function initExportPNGConfirmationDialog(param1:InputManager, param2:String, param3:File) : void
  225.       {
  226.          super.init(param1);
  227.          if(param2.indexOf("/") != -1)
  228.          {
  229.             param2 = param2.substr(param2.lastIndexOf("/") + 1);
  230.          }
  231.          _existingFileName = param2;
  232.          _newFile = param3;
  233.          _message.text = "A file called " + _existingFileName + ".png already exists.\n\nWould you like to replace it or create a new file called " + _newFile.name + "?";
  234.          defaultButton = _createNew;
  235.          _createNew.setFocus();
  236.       }
  237.       
  238.       public function ___createNew_click(param1:MouseEvent) : void
  239.       {
  240.          onClick(param1);
  241.       }
  242.       
  243.       public function set kind(param1:Boolean) : void
  244.       {
  245.          _kind = param1;
  246.          title = _kind == KIND_MULTIPLE ? "Export All Snapshots as PNG" : "Export Snapshot to PNG";
  247.          _replaceAll.includeInLayout = _replaceAll.visible = _kind == KIND_MULTIPLE;
  248.       }
  249.       
  250.       public function set _message(param1:Text) : void
  251.       {
  252.          var _loc2_:Object = this._981817656_message;
  253.          if(_loc2_ !== param1)
  254.          {
  255.             this._981817656_message = param1;
  256.             this.dispatchEvent(PropertyChangeEvent.createUpdateEvent(this,"_message",_loc2_,param1));
  257.          }
  258.       }
  259.       
  260.       [Bindable(event="propertyChange")]
  261.       public function get _replace() : Button
  262.       {
  263.          return this._842245771_replace;
  264.       }
  265.       
  266.       override public function closeYourself() : void
  267.       {
  268.          _createNew.removeEventListener(MouseEvent.CLICK,onClick);
  269.          super.closeYourself();
  270.       }
  271.       
  272.       [Bindable(event="propertyChange")]
  273.       public function get _replaceAll() : Button
  274.       {
  275.          return this._144754708_replaceAll;
  276.       }
  277.    }
  278. }
  279.  
  280.